package com.leyou.item.client;

import com.leyou.common.vo.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {

    //    GET /brand/of/category?id=76
    @GetMapping(value = "/brand/of/category",name = "根据分类id查询品牌数据")
    public List<BrandDTO> findBrandListByCategoryId(@RequestParam("id") Long id);


    @GetMapping(value = "/spu/page",name = "分页查询spu数据")
    public PageResult<SpuDTO> findSpuByPage(
            @RequestParam(value = "page",defaultValue = "1") Integer page,
            @RequestParam(value = "rows",defaultValue = "5") Integer rows,
            @RequestParam(value = "key",required = false) String key,
            @RequestParam(value = "saleable",required = false) Boolean saleable
    );
;

    @GetMapping(value = "/spu/detail",name = "根据spuId查询SPUDetail")
    public SpuDetailDTO findSpuDetailBySpuId(@RequestParam("id") Long id);

    @GetMapping(value = "/sku/of/spu",name = "根据spuId查询sku列表数据")
    public List<SkuDTO> findSkuListBySpuId(@RequestParam("id") Long id);


    @GetMapping(value = "/spec/params",name ="根据分类id或组id查询规格参数数据" )
//    gid  cid  searching
    public List<SpecParamDTO> findSpecParamByCategoryIdOrGroupId(
            @RequestParam(value = "gid" ,required = false) Long gid,
            @RequestParam(value ="cid" ,required = false) Long cid,
            @RequestParam(value ="searching",required = false) Boolean searching
    );

    @GetMapping (value = "/brand/list",name = "根据品牌id集合查询品牌集合数据")
    public List<BrandDTO> findBrandListByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping(value = "/category/list/" ,name = "根据分类ids查询分类数据")
    public List<CategoryDTO> findCategoryListByIds(@RequestParam(name = "ids") List<Long> ids);

    @GetMapping(value = "/spu/{id}",name = "根据spuId查询spu对象")
    public SpuDTO findSpuBySpuId(@PathVariable("id") Long id);

    @GetMapping (value = "/brand/{id}",name = "根据品牌id获取品牌数据")
    public BrandDTO findBrandById(@PathVariable("id") Long id);

    @GetMapping(value = "/spec/of/category",name ="根据分类id或组id查询规格参数数据" )
    public List<SpecGroupDTO> findSpecGroupWithParamsByCategoryId(@RequestParam(value = "id") Long id);

    @GetMapping(value = "/sku/list",name = "根据skuId集合查询sku对象集合")
    public List<SkuDTO> findSkuListBySkuIds(@RequestParam("ids") List<Long> ids);

    @PutMapping(value = "/stock/minus",name = "减库存")
    public Void stockMinus(@RequestBody Map<Long,Integer> skuIdAndNumMap);


    @PutMapping(value = "/stock/plus",name = "恢复库存")
    public Void stockPlus(@RequestBody Map<Long,Integer> skuIdAndNumMap);
}
